package test.client43;

import java.util.logging.Logger;

import org.apache.http.HttpHost;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;

public class ClientTest03 {
	private static final Logger log = Logger.getLogger(ClientTest03.class.getName());
	public static void main( String args[] ) throws Exception {
		new ClientTest03().go();
	}

	private void go() throws Exception {
		HttpClientContext ctx = HttpClientContext.create();
		CloseableHttpClient cl = HttpClients.custom().build();
		HttpGet get = new HttpGet("http://dir.yahoo.co.jp/Entertainment/Music/?q=Music");
		log.info(get.toString());
		CloseableHttpResponse r = cl.execute(get,ctx);
		try {
			log.info(r.getStatusLine().toString());
			HttpHost host = ctx.getTargetHost();
			log.info("httphost is "+host);
			log.info("httphostname is "+host.getHostName());
		} finally {
			r.close();
		}
	}
}
